/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Employee;

import Academic.AcademicBean;
import Address.AddressBean;
import Admission.AdmissionBean;
import Category.CategoryBean;
import Country.CountryBean;
import Course.CourseBean;
import Department.DepartmentBean;
import Designation.DesignationBean;
import Facility.FacilityBean;
import Parents.ParentsBean;
import State.StateBean;
import Student.StudentBean;
import User.UserBean;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author mishra
 */
public class getEmployeeDetails extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            int aid = Integer.parseInt(request.getParameter("aId"));
            EmployeeBean eb = Employee.Query.viewSpecificLib("user_id", aid);
            AddressBean ab = eb.getAddressBean();
            StateBean sb = ab.getStateBean();
            CountryBean cb = ab.getCountryBean();
            DepartmentBean db = eb.getDepartmentBean();
            DesignationBean dib = eb.getDesignationBean();
            UserBean ub = eb.getUserBean();

            out.println("<a href = 'javascript:void(0)' onclick='quickClose()'><span id='quickclose'><img src='../../img/close.png'></span></a>");
            out.println("<div id='records'>");

            out.println("<div class='rowood'>");
            out.println("<div><b>Employee Id:&nbsp; </b>" + eb.getEmployeeId() + "</div>");
            out.println("<div><b>Employee Email :&nbsp; </b>" + ub.getEntryEmail() + "</div>");
            out.println("</div>");

            out.println("<div class='roweven'>");
            out.println("<div><b>Employee Name :&nbsp; </b>" + ub.getEmployeeName()+ "</div>");
            out.println("<div><b>Department :&nbsp; </b>" + db.getDepartmentName()+ "</div>");
            out.println("</div>");

            out.println("<div class='rowood'>");
            out.println("<div><b>Designation :&nbsp; </b>" + dib.getDesignation() + "</div>");
            out.println("<div><b>Mobile Number :&nbsp; </b>" + eb.getMobile() + "</div>");
            out.println("</div>");

            out.println("<div class='roweven'>");
            out.println("<div><b>Phone Number :&nbsp; </b>" + eb.getPhone() + "</div>");
            out.println("<div><b>Employee Type :&nbsp; </b>" + eb.getEmployeeType() + "</div>");
            out.println("</div>");

            out.println("<div class='rowood'>");
            out.println("<div><b>joining Date :&nbsp; </b>" +eb.getDoj() + "</div>");
            out.println("<div><b>Gender :&nbsp; </b>" + eb.getGender() + "</div>");
            out.println("</div>");

            out.println("<div class='roweven'>");
            out.println("<div><b>Address1 :&nbsp; </b>" + ab.getAddress1() + "</div>");
            out.println("<div><b>Address2 :&nbsp; </b>" + ab.getAddress2() + "</div>");
            out.println("</div>");

            out.println("<div class='rowood'>");
            out.println("<div><b>Pin Code:&nbsp; </b>" + ab.getPinCode() + "</div>");
            out.println("<div><b>State :&nbsp; </b>" + sb.getStateName() + "</div>");
            out.println("</div>");

            out.println("<div class='roweven'>");
            out.println("<div><b>Country:&nbsp; </b>" + cb.getCountryName() + "</div>");
            out.println("</div>");

            out.println("</div>");
        } catch (Exception e) {
            out.println(e);
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
